package org.dormi.learn.primitive;

import org.dormi.learn.utils.Assert;

import java.util.Objects;

/**
 * 价格
 *
 * @author : dormi330
 * @version : 1.0
 */
public class Price extends _Primitive_ {

    /** 价格类型, 如 淘宝价/天猫价/京东价/最低价/最高价/吊牌价/.... */
    private final PriceType type;

    /** 对应的价格 */
    private final Money money;

    /* === constructor === */
    /* === constructor === */
    /* === constructor === */

    public Price(PriceType type, Money money) {
        Assert.isNotNull(type, "不能为null: Price.type");
        Assert.isNotNull(money, "不能为null: Price.money");

        this.type = type;
        this.money = money;
    }

    /* === hash/equals === */
    /* === hash/equals === */
    /* === hash/equals === */

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Price)) return false;
        Price price = (Price) o;
        return Objects.equals(getType(), price.getType()) &&
                Objects.equals(getMoney(), price.getMoney());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getType(), getMoney());
    }

    /* === set/get === */
    /* === set/get === */
    /* === set/get === */

    public PriceType getType() {
        return type;
    }

    public Money getMoney() {
        return money;
    }

}
